import { invoke } from "@tauri-apps/api/core";

export const getMusicData = async () => {
  const data = await invoke("get_music_data");
  return JSON.parse(data);
};

export const getMusicPlayUrl = async (row) => {
  const params = {
    mid: row.mid,
    mediaMid: row.file.media_mid,
    s: "M500",
    e: ".mp3",
  };

  const dataStr = await invoke("get_music_url", params);
  const data = JSON.parse(dataStr);
  const url = data.req_0.data.sip[0] + data.req_0.data.midurlinfo[0].purl
  return url;
};
